package IO流.InputStream01;

import org.junit.jupiter.api.Test;

import java.io.*;
@SuppressWarnings("all")
public class BufferedInputStream01 {

    @Test
    public void bufferedInputStream(){
        String srcFilePath = "src/main/java/IO流/包装流/节点流和处理流.png";
        String desFilePath = "src/main/java/IO流/InputStream01/1.png";

        BufferedInputStream bufferedInputStream = null;
        BufferedOutputStream bufferedOutputStream = null;

        try {
            bufferedInputStream = new BufferedInputStream(new FileInputStream(srcFilePath));
            bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(desFilePath));
            byte[] buff = new byte[1024];
            int dataLen = 0;
            while ((dataLen = bufferedInputStream.read(buff)) != -1){
                bufferedOutputStream.write(buff,0,dataLen);
            }
            System.out.println("拷贝完成");

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                bufferedInputStream.close();
                bufferedOutputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
